package com.teach.flavour.enums;
import com.common.utils.IBaseEnum;

import java.util.Arrays;
import java.util.Optional;

/**
 * @author hzz
 */

public enum SourRank implements IBaseEnum {
    BUSUAN(1, "不酸"),
    NORMAL(2, "正常"),
    PIANSUAN(3, "偏酸"),
    KEPA(4, "超酸");

    private Integer value;
    private String text;

    SourRank(int value, String text) {
        this.value = value;
        this.text = text;
    }
    public synchronized static SourRank fromCode(Integer code) {
        if (null != code) {
            Optional<SourRank> optional = Arrays.asList(SourRank.values()).stream().filter(x -> x.getValue() - code == 0).findAny();
            return optional.isPresent() ? optional.get() : null;
        }

        return null;
    }
    public synchronized static SourRank textOf(String text) {
        if (null != text) {
            Optional<SourRank> optional = Arrays.asList(SourRank.values()).stream().filter(x -> x.getText().equals(text)).findAny();
            return optional.isPresent() ? optional.get() : null;
        }

        return null;
    }
    @Override
    public int getValue() {
        return this.value;
    }

    @Override
    public String getText() {
        return this.text;
    }

    @Override
    public String paraString() {
        return this.paraString();
    }
}
